#ifndef MISC_HPP
#define MISC_HPP

#include <windows.h>
#include <stdio.h>
#include <functional>
#include <math.h>

namespace Dynamic
{

struct TimedVoxels;
struct SystemMatrix;

// random
double rnd_0_1();
// lg
const double logbase = 1.3;

double logb(double x);

// square
double sqr(const double& a);

// sign function
double sign(double x);

// Print TGA header
void PrintTGAHeader(FILE* ofile, int width, int height);

// Print TGA header
void PrintTGAColor(FILE* ofile, double value, double gamma = 0.8);

void Message(char* buffer, bool up);

// Gauss PDF
double Gauss2D(double dist, double sigma);
double Gauss1D(double dist, double sigma);

//
// generates Poisson distributed random variables of mean lambda
//
unsigned int poisson(double lambda);

void PoissonRandomize(double* array, int nelems, int nsamples);

// Base functions
double linearUniformTentBasisFunction(double dt, int timeSliceId, double t);

int getRandomVoxel(TimedVoxels& x);
int getRandomLorForVoxel(int voxelIndex, SystemMatrix& A_LV);

double woodcockTrackEmissionTime(std::function<double(double, double, double)> inverseProbFunc,
								 std::function<double(double)> timeDensityFunc, double xMax, double tMax);

}

#endif // MISC_HPP
